﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

namespace DELVE_GAME.ViewStructure
{
    class TimeDrawer : TextComponent
    {
        SpriteFont font;
        String str = "";
        Game game;

        public TimeDrawer(Game game, SpriteFont font, int x, int y) : base(font, x, y)
        {
            this.font = font;
            this.x = x;
            this.y = y;
            this.game = game;
        }

        public void setString(String str)
        {
            this.str = str;
        }

        public void setFont(SpriteFont font)
        {
            this.font = font;
        }

        public override void draw(Microsoft.Xna.Framework.Graphics.SpriteBatch sb)
        {
            if (font == null)
            {
                throw new InvalidOperationException("This object currently has no font set.");
            }
            sb.Begin();
            sb.DrawString(font, str, new Vector2(this.x, this.y), Color.White); ;
            sb.End();
            this.setString("");
        }

        public override void update()
        {
            if (game.hasTimeLimit())
            {
                this.setString("Turn over in: "+game.getRemainingTime());
            }
        }

        public override void mouseOver(int x, int y)
        {
            //throw (new NotImplementedException());
        }

        public override void mousePressed(int x, int y)
        {
            //throw (new NotImplementedException());
        }

        public override void mouseReleased(int x, int y)
        {
            //throw (new NotImplementedException());
        }

        public override void keyPressed(Microsoft.Xna.Framework.Input.Keys key)
        {
            //throw (new NotImplementedException());
        }

        public override void keyReleased(Microsoft.Xna.Framework.Input.Keys key)
        {
            //throw (new NotImplementedException());
        }
    }
}
